﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterALSafa.Master" AutoEventWireup="true"
    CodeBehind="Buses.aspx.cs" Inherits="School.Pages.Bus.Buses" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <style type="text/css">
        body
        {
            font-family: Arial, Helvetica, sans-serif;
        }
        #status
        {
            font-size: 11px;
            margin: 10px;
        }
        .availablecss
        {
            background-color: #CEFFCE;
            border: 1px solid green;
        }
        .notavailablecss
        {
            background-color: #FFD9D9;
            border: 1px solid red;
        }
        #view
        {
            display: none;
        }
    </style>
    <table dir="rtl" style="width: 100%; float: right" width="100%">
        <tr>
            <td>
                <div id="search">
                    <asp:Panel ID="PLsearch" runat="server">
                        <table align="right" dir="rtl" style="width: 100%; float: right">
                            <tr>
                                <td nowrap="nowrap">
                                    المجمع
                                </td>
                                <td>
                                    <asp:DropDownList ID="ddCamp" runat="server" AppendDataBoundItems="True" DataTextField="Name"
                                        DataValueField="Id" Width="153px">
                                    </asp:DropDownList>
                                </td>
                            </tr>
                            <tr>
                                <td nowrap="nowrap">
                                    كود الباص
                                </td>
                                <td>
                                    <asp:TextBox ID="txtcodese" runat="server" Width="150px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td nowrap="nowrap">
                                    اسم&nbsp; الباص
                                </td>
                                <td>
                                    <asp:TextBox ID="txtNamese" runat="server" Width="150px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td nowrap="nowrap">
                                    عدد الركاب
                                </td>
                                <td>
                                    <asp:TextBox ID="txtPassengerse" runat="server" Width="150px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    &nbsp;
                                </td>
                                <td>
                                    <asp:Button ID="btnsearch" runat="server" CssClass="graybutton" OnClick="btnsearch_Click"
                                        Text="بحث" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    &nbsp;
                                </td>
                                <td>
                                    <asp:Label ID="lbltestBusse" runat="server" Visible="False"></asp:Label>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    &nbsp;
                                </td>
                                <td>
                                    <asp:Literal ID="lblRecordNo" runat="server"></asp:Literal>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    &nbsp;
                                </td>
                                <td>
                                    <asp:GridView ID="gvbus" runat="server" AllowPaging="True" AlternatingRowStyle-CssClass="GridItemAltername"
                                        AutoGenerateColumns="False" CssClass="Grid" DataKeyNames="Id" FooterStyle-CssClass="GridHeaderFooter"
                                        HeaderStyle-CssClass="GridHeaderFooter" OnRowCancelingEdit="gvbus_RowCancelingEdit"
                                        OnRowDeleting="gvbus_RowDeleting" OnRowEditing="gvbus_RowEditing" OnRowUpdating="gvbus_RowUpdating"
                                        PagerStyle-CssClass="GridPager" OnRowDataBound="gvbus_RowDataBound" OnPageIndexChanging="gvbus_PageIndexChanging">
                                        <AlternatingRowStyle CssClass="GridItemAltername" />
                                        <Columns>
                                            <asp:TemplateField>
                                                <HeaderTemplate>
                                                    م
                                                </HeaderTemplate>
                                                <ItemTemplate>
                                                    <%# Container.DataItemIndex + 1 %>
                                                </ItemTemplate>
                                                <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                            </asp:TemplateField>
                                            <asp:BoundField DataField="Name" HeaderText="المجمع" ReadOnly="True" SortExpression="Name">
                                                <HeaderStyle BorderStyle="None" HorizontalAlign="Center" VerticalAlign="Middle" />
                                                <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                            </asp:BoundField>
                                            <asp:TemplateField HeaderText="إسم الباص" SortExpression="busname">
                                                <EditItemTemplate>
                                                    <asp:TextBox ID="txtbname" runat="server" Text='<%# Bind("busname") %>' 
                                                        MaxLength="50"></asp:TextBox>
                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator10" runat="server" ControlToValidate="txtbname"
                                                        Display="Dynamic" ErrorMessage="*" ForeColor="Red" ValidationGroup="gvb">*</asp:RequiredFieldValidator>
                                                </EditItemTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("busname") %>'></asp:Label>
                                                </ItemTemplate>
                                                <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                                <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="كود الباص" SortExpression="Bus_Code">
                                                <EditItemTemplate>
                                                    <asp:TextBox ID="txtbcode" runat="server" Text='<%# Bind("Bus_Code") %>'></asp:TextBox>
                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator11" runat="server" ControlToValidate="txtbcode"
                                                        Display="Dynamic" ErrorMessage="*" ForeColor="Red" ValidationGroup="gvb">*</asp:RequiredFieldValidator>
                                                </EditItemTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("Bus_Code") %>'></asp:Label>
                                                </ItemTemplate>
                                                <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                                <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="عدد الركاب" SortExpression="Passenger_number">
                                                <EditItemTemplate>
                                                    <asp:TextBox ID="txtbPassenger" runat="server" Text='<%# Bind("Passenger_number") %>'></asp:TextBox>
                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator12" runat="server" ControlToValidate="txtbPassenger"
                                                        Display="Dynamic" ErrorMessage="*" ForeColor="Red" ValidationGroup="gvb">*</asp:RequiredFieldValidator>
                                                    <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToValidate="txtbPassenger"
                                                        Display="Dynamic" ErrorMessage="أدخل ارقام" ForeColor="Red" Operator="DataTypeCheck"
                                                        Type="Integer" ValidationGroup="gvb"></asp:CompareValidator>
                                                </EditItemTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="Label4" runat="server" Text='<%# Bind("Passenger_number") %>'></asp:Label>
                                                </ItemTemplate>
                                                <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                                <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="ملاحظات" SortExpression="note">
                                                <EditItemTemplate>
                                                    <asp:TextBox ID="txtbnote" runat="server" Text='<%# Bind("note") %>' TextMode="MultiLine"></asp:TextBox>
                                                </EditItemTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="Label3" runat="server" Text='<%# Bind("note") %>'></asp:Label>
                                                </ItemTemplate>
                                                <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                                <ItemStyle Width="300px" />
                                            </asp:TemplateField>
                                            <asp:CommandField CancelText="إلغاء" EditText="تعديل" ShowEditButton="True" UpdateText="تحديث"
                                                ValidationGroup="gvb">
                                                <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                                <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                            </asp:CommandField>
                                            <asp:TemplateField ShowHeader="False">
                                                <ItemTemplate>
                                                    <asp:LinkButton ID="lkdelete" runat="server" CausesValidation="False" CommandName="Delete"
                                                        Text="حذف"></asp:LinkButton>
                                                </ItemTemplate>
                                                <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                                <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                            </asp:TemplateField>
                                        </Columns>
                                        <FooterStyle CssClass="GridHeaderFooter" />
                                        <HeaderStyle CssClass="GridHeaderFooter" />
                                        <PagerStyle CssClass="GridPager" />
                                    </asp:GridView>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                </td>
                                <td>
                                    <input type="button" name="إضافة" value="إضافة" id="btnAdd" class="graybutton" />
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                </div>
            </td>
        </tr>
        <tr>
            <td>
                <div id="view">
                    <asp:Panel ID="Plview" runat="server">
                        <table align="right" dir="rtl" style="width: 964px">
                            <tr>
                                <td>
                                    المجمع
                                </td>
                                <td>
                                    <asp:DropDownList ID="ddCamp1" runat="server" DataTextField="Name" DataValueField="Id"
                                        Width="153" AppendDataBoundItems="True">
                                    </asp:DropDownList>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="ddCamp1"
                                        Display="Dynamic" ErrorMessage="*" ForeColor="Red" ValidationGroup="bu" InitialValue="-1">*</asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    كود الباص
                                </td>
                                <td>
                                    <asp:TextBox ID="txtcode" runat="server" Width="150px"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" ControlToValidate="txtcode"
                                        Display="Dynamic" ErrorMessage="*" ForeColor="Red" ValidationGroup="bu">*</asp:RequiredFieldValidator>
                                    <span id="status"></span>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    إسم الباص
                                </td>
                                <td>
                                    <asp:TextBox ID="txtName" runat="server" Width="150px" MaxLength="50"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server" ControlToValidate="txtName"
                                        Display="Dynamic" ErrorMessage="*" ForeColor="Red" ValidationGroup="bu">*</asp:RequiredFieldValidator>
                                    <span id="statusbus"></span>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    عدد الركاب
                                </td>
                                <td>
                                    <asp:TextBox ID="txtPassenger" runat="server" Width="150px"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtPassenger"
                                        Display="Dynamic" ErrorMessage="*" ForeColor="Red" ValidationGroup="bu">*</asp:RequiredFieldValidator>
                                    <asp:CompareValidator ID="CompareValidator2" runat="server" ErrorMessage="أدخل رقم"
                                        ValidationGroup="bu" Text="أدخل رقم" Display="Dynamic" ControlToValidate="txtPassenger"
                                        ForeColor="Red" Operator="DataTypeCheck" Type="Integer"></asp:CompareValidator>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    ملاحظات
                                </td>
                                <td>
                                    <asp:TextBox ID="txtnote" runat="server" Width="200px" Height="192px" TextMode="MultiLine"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    &nbsp;
                                </td>
                                <td>
                                    <asp:Button ID="btnSaveStation" runat="server" OnClick="btnSaveStation_Click" Text="حفظ"
                                        CssClass="graybutton" ValidationGroup="bu" />
                                    &nbsp;
                                    <input type="button" name="إلغاء" value="إلغاء" id="btnexit" class="graybutton" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    &nbsp;
                                </td>
                                <td>
                                    <asp:Literal ID="lbltestBus" runat="server" Visible="False"></asp:Literal>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                </td>
                                <td>
                                    &nbsp;
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                </div>
            </td>
        </tr>
    </table>
    <script src="../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">


        $(document).ready(function () {
            $('#<%= txtcode.ClientID%>').blur(function () {
                var uname = $('#<%= txtcode.ClientID%>');
                var msgbox = $("#status");
                if (uname.val().length > 0) {
                    $.ajax({
                        type: "POST",
                        url: "Buses.aspx/CheckCode",
                        data: "{'args': '" + uname.val() + "'}",
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (msg) {
                            if (msg.d == 'Available') {
                                uname.removeClass("notavailablecss");
                                uname.addClass("availablecss");
                                msgbox.html('<img src="../images/a.png"/> <font color="Green"> متاح </font>');
                            }


                            else {
                                uname.removeClass("availablecss");
                                uname.addClass("notavailablecss");
                                msgbox.html(msg.d);
                            }
                        }
                    });
                }
                else {

                    uname.addClass("notavailablecss");
                    msgbox.html('<font color="#cc0000">أدخل الكود</font>');
                }
            });

        });


        $(document).ready(function () {
            $('#<%= txtName.ClientID%>').blur(function () {
                var uname = $('#<%= txtName.ClientID%>');
                var msgbox = $("#statusbus");
                if (uname.val().length > 0) {
                    $.ajax({
                        type: "POST",
                        url: "Buses.aspx/CheckName",
                        data: "{'args': '" + uname.val() + "'}",
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (msg) {
                            if (msg.d == 'Available') {
                                uname.removeClass("notavailablecss");
                                uname.addClass("availablecss");
                                msgbox.html('<img src="../images/a.png"/> <font color="Green"> متاح </font>');
                            }


                            else {
                                uname.removeClass("availablecss");
                                uname.addClass("notavailablecss");
                                msgbox.html(msg.d);
                            }
                        }
                    });
                }
                else {

                    uname.addClass("notavailablecss");
                    msgbox.html('<font color="#cc0000">أدخل الاسم</font>');
                }
            });
        });


        //start




        //end
        $(document).ready(function () {

            $("#btnAdd").click(function () {
                $("#search").hide();
                $("#view").show();
            });

            $("#btnexit").click(function () {
                $("#view").hide();
                $("#search").show();
            });
        });
    </script>
</asp:Content>
